import socket

def send_udp_message(message, ipv6_address, port):
    # 创建 IPv6 UDP socket
    sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)

    try:
        # 发送消息到指定的 IPv6 地址和端口
        sock.sendto(message.encode(), (ipv6_address, port))
        print("UDP 消息已发送到", ipv6_address, "端口", port)
    finally:
        # 关闭 socket 连接
        sock.close()

# 要发送的消息
message = "Hello, UDP!"

# 目标 IPv6 地址和端口
ipv6_address = "fe80::ebc4:e5d:8236:923c"
port = 8887



# 发送 UDP 消息
send_udp_message(message, "fe80::bbb7:7753:6cf1:d33f", port)
send_udp_message(message, "fe80::6462:ad3a:227a:e6d", port)
send_udp_message(message, "fe80::ebc4:e5d:8236:923c", port)
